﻿using System;
using Loki.Utilities.Plugins;

namespace WindowPlacer
{
    public class Main : IPlugin
    {

        public static WindowInfo MyWindowsPosition = new WindowInfo();

        #region Implementation of IEquatable<IPlugin>

        /// <summary>
        ///     Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        ///     true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
        /// </returns>
        /// <param name="other">An object to compare with this object.</param>
        public bool Equals(IPlugin other)
        {
            return Name.Equals(other.Name);
        }

        #endregion

        #region Implementation of IPlugin

        /// <summary> </summary>
        public string Author
        {
            get { return "toNyx"; }
        }

        /// <summary> </summary>
        public Version Version
        {
            get { return new Version(0, 1, 0, 0); }
        }

        /// <summary> </summary>
        public string Name
        {
            get { return "WindowPlacer"; }
        }

        /// <summary> </summary>
        public string Description
        {
            get { return "Place Exilebuddy's Window"; }
        }

        /// <summary>
        /// Executes the initialize action. This is called at initial bot startup. (When the bot itself is started, not when Start() is called) 
        /// </summary>
        public void OnInitialize()
        {
            // Initialize default position to avoid shit if file doesn't exists
            if (MyWindowsPosition.GetInformations() == false)
                MyWindowsPosition = new WindowInfo(20, 20, 627, 440, 20, 20, 816, 638);

            MyWindowsPosition.PlaceWindow();      
        }

        /// <summary>
        /// Executes the start action. This is called when the bot starts. 
        /// </summary>
        public void OnStart()
        {
        }

        /// <summary>
        /// Executes the pulse action. This is called every "tick" of the bot. 
        /// </summary>
        public void OnPulse()
        {
        }

        /// <summary>
        /// Executes the stop action. This is called when the bot is stopped. 
        /// </summary>
        public void OnStop()
        {
        }

        /// <summary>
        /// Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) 
        /// </summary>
        public void OnShutdown()
        {
            MyWindowsPosition.SaveInformations();
        }

        /// <summary>
        /// Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. 
        /// </summary>
        public void OnEnabled()
        {
        }

        /// <summary>
        /// Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. 
        /// </summary>
        public void OnDisabled()
        {
        }

        /// <summary>
        /// Executes the config action. This is called when the user clicks on the config button.
        /// </summary>
        public void OnConfig()
        {
            var myForm = new SettingsForm(Helpers.GetForegroundWindow());
            myForm.Show();
        }

        #endregion
    }
}
